home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 8: LINUX Games / Linux Cubed Series 8 - LINUX Games.iso / games / x11 / rpg / crossfir.92 / crossfir / crossfire-0.92.5 / crossedit / CrUtil.c < prev    next >
C/C++ Source or Header  |  1996-07-24  |  2KB  |  75 lines

  1. #include <Defines.h>
  2. #include <global.h>
  3. #include <debug.h>
  4. #include <xio.h>
  5. #include <X11.h>
  6. #include <CrUtil.h>
  7.  
  8. extern    Pixmap *pixmaps;       /* list of pixmaps */
  9. extern    Pixmap *masks;       /* list of pixmaps */
  10.  
  11. /*
  12.  *Function: FaceDraw
  13.  *Member-Of: Cr
  14.  *Description:
  15.  * Draw face into position.
  16.  *Commentary:
  17.  * There are inplicit use of use_pixmaps and color_pix, that should
  18.  * be removed by better structuring of program.
  19.  */
  20. void FaceDraw (Widget w, GC gc, New_Face *face, int x, int y) {
  21.     XChar xbuf;
  22.  
  23.     if(color_pix) {
  24.     XSetClipMask(XtDisplay (w), gc, masks[face->number]);
  25.     XSetClipOrigin(XtDisplay (w), gc, x, y);
  26.     XCopyArea(XtDisplay (w), pixmaps[face->number],
  27.           XtWindow(w), gc, 0, 0, FONTSIZE, FONTSIZE, x, y);
  28.     } else {
  29.     if (HAS_COLOUR(w)) {
  30.         XSetForeground (XtDisplay (w), gc, discolor[face->fg].pixel);
  31.         XSetBackground (XtDisplay (w), gc, discolor[face->bg].pixel);
  32.     }
  33.     else {
  34.         XSetForeground (XtDisplay (w), gc, BlackPixel(XtDisplay(w),    
  35.         XScreenNumberOfScreen(XtScreen(w))));
  36.         XSetBackground (XtDisplay (w), gc, WhitePixel(XtDisplay(w),
  37.         XScreenNumberOfScreen(XtScreen(w))));
  38.     }
  39.     if (use_pixmaps) {
  40.         XCopyPlane(XtDisplay (w), pixmaps[face->number], 
  41.                XtWindow(w), gc, 0, 0, FONTSIZE, FONTSIZE, x, y, 1);
  42.     } else {
  43.         xbuf = FontindexToXChar (face->number);
  44.         XDRAWIMAGESTRING (XtDisplay (w),XtWindow(w), gc, 
  45.                   x, y + 24, &xbuf, 1);
  46.  
  47.     }
  48.     }
  49. }
  50.  
  51. /*
  52.  *Function: GCCreate
  53.  *Member-Of: Cr
  54.  *Description:
  55.  * Create suitable GC for Cr widgets.
  56.  *Commentary:
  57.  * There are inplicit use of use_pixmaps and color_pix, that should
  58.  * be removed by better structuring of program.
  59.  */
  60. GC GCCreate (Widget w) {
  61.     XGCValues values;
  62.     GC gc;
  63.     if (use_pixmaps || color_pix)
  64.     gc= XtAllocateGC (w, 0, 0L, NULL, GCBackground | GCForeground, 0);
  65.     else {
  66.     values.font = XLoadFont (XtDisplay(w),FONTNAME);
  67.     gc= XtAllocateGC 
  68.         (w, 0, GCFont, &values, GCBackground | GCForeground, 0);
  69.     }
  70.     XSetGraphicsExposures(XtDisplay(w), gc, False);
  71.    return gc;
  72. }
  73.  
  74.  
  75.